<template>
  <div class="main c-l-t m-b-12">
    <span></span>
    <span></span>
    <span></span>
    <span></span>
    <div class="main-border">
      <div class="disFlexItem m-b-12 p-12">
        <div class="tit">今日群动态</div>
        <div>
          <img src="../assets/img/left.png" alt="" srcset="" />
        </div>
      </div>
      <div class="p-30">
        <div class="disFlexItem m-b-30">
          <div class="c-l-t-card m-r-20">
            <div class="center font-c">健康</div>
            <div class="center num-c">{{ healthlist }}</div>
            <div class="triangle"></div>
          </div>
          <div class="c-l-t-card">
            <div class="center font-c">咨询</div>
            <div class="center num-c">{{ advicelist }}</div>
            <div class="triangle"></div>
          </div>
        </div>
        <div class="disFlexItem m-b-30">
          <div class="c-l-t-card m-r-20">
            <div class="center font-c">商城</div>
            <div class="center num-c">{{ shoplist }}</div>
            <div class="triangle"></div>
          </div>
          <div class="c-l-t-card">
            <div class="center font-c">服务</div>
            <div class="center num-c">{{ servicelist }}</div>
            <div class="triangle"></div>
          </div>
        </div>
        <div class="disFlexItem">
          <div class="c-l-t-card m-r-20">
            <div class="center font-c">活动</div>
            <div class="center num-c">{{ activelist }}</div>
            <div class="triangle"></div>
          </div>
          <div class="c-l-t-card">
            <div class="center font-c">预警</div>
            <div class="center num-c">{{ yjList }}</div>
            <div class="triangle"></div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { mapState } from "vuex";
export default {
  computed: {
    // 使用 mapState 函数将 state 中的数据映射到组件的计算属性中
    ...mapState(["yjList"]),
  },
  mounted() {
    this.$nextTick(() => {
      console.log("nexttick");
      // this.yjList = this.$store.state.yjList;
      this.healthlist = this.$store.state.healthlist;
      this.advicelist = this.$store.state.advicelist;
      this.shoplist = this.$store.state.shoplist;
      this.servicelist = this.$store.state.servicelist;
      this.activelist = this.$store.state.activelist;
    });
    setInterval(() => {
      this.$store.dispatch("addhealthlist");
      this.$store.dispatch("addadvicelist");
      this.$store.dispatch("addshoplist");
      this.$store.dispatch("addservicelist");
      this.$store.dispatch("addactivelist");
      this.$nextTick(() => {
        console.log("nexttick");
        // this.yjList = this.$store.state.yjList;
        this.healthlist = this.$store.state.healthlist;
        this.advicelist = this.$store.state.advicelist;
        this.shoplist = this.$store.state.shoplist;
        this.servicelist = this.$store.state.servicelist;
        this.activelist = this.$store.state.activelist;
      });
    }, 60000);
    // console.log("this.$store.state.yjList", this.$store.state.yjList);
  },
  data() {
    return {
      // yjList: "",
      healthlist: "",
      advicelist: "",
      shoplist: "",
      servicelist: "",
      activelist: "",
    };
  },
};
</script>

<style scoped>
.main {
  position: relative;
  border: 1px solid #192856;
  padding: 12px;
  box-sizing: border-box;
}
.c-l-t {
  height: 100%;
}
.m-b-12 {
  margin-bottom: 20px;
}
.main .main-border {
  border: 1px solid #202d56;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
}
.disFlexItem {
  display: flex;
  justify-items: center;
  justify-content: space-between;
}
.p-12 {
  padding: 0 12px;
}
.p-30 {
  padding: 0 30px 15px;
  box-sizing: border-box;
}
.m-b-30 {
  margin-bottom: 25px;
}
.main-border .c-l-t-card {
  width: 47%;
  height: 80px;
  background-image: url("../assets/img/bg1.jpg");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  position: relative;
  padding: 10px 0;
  box-sizing: border-box;
}
.main-border .c-l-t-card .center {
  text-align: center;
}
.main-border .triangle {
  border-top: 10px solid rgba(0, 0, 0, 0);
  border-bottom: 10px solid rgba(0, 0, 0, 0);
  border-right: 10px solid rgba(0, 0, 0, 0);
  border-left: 10px solid #fff;
  background-color: rgba(0, 0, 0, 0);
  position: absolute;
  top: -10px;
  right: -10px;
  transform: rotate(-45deg);
}
.num-c {
  color: #fe7007;
  font-size: 30px;
  font-weight: bold;
}

.font-c {
  color: #0ee4f9;
  font-size: 18px;
}
.tit {
  color: #fff;
  font-size: 18px;
  font-weight: bold;
  flex-shrink: 0;
}
.main span:nth-child(1) {
  position: absolute;
  left: -1px;
  top: -1px;
  padding: 10px;
  border-style: solid;
  border-color: #00c7d6;
  border-width: 2px 0 0 2px;
}

.main span:nth-child(2) {
  position: absolute;
  right: -1px;
  top: -1px;
  padding: 10px;
  border-style: solid;
  border-color: #00c7d6;
  border-width: 2px 2px 0 0;
}

.main span:nth-child(3) {
  position: absolute;
  right: -1px;
  bottom: -1px;
  padding: 10px;
  border-style: solid;
  border-color: #00c7d6;
  border-width: 0 2px 2px 0;
}

.main span:nth-child(4) {
  position: absolute;
  left: -1px;
  bottom: -1px;
  padding: 10px;
  border-style: solid;
  border-color: #00c7d6;
  border-width: 0 0 2px 2px;
}
</style>
